tests/boot_linux_console: add a test for riscv64 + virt
PATCH v2 1/1 tests/boot_linux_console: add a test for riscv64 + virt
Similar to the mips + malta test, it boots a Linux kernel on a virt board and verify the serial is working. Also, it relies on the serial device set by the machine itself.
If riscv64 is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:riscv64" tags.
Alternatively, this test can be run using:
$ avocado run -t arch:riscv64 tests/acceptance
packages
debian official
binutils-riscv64-linux-gnu_2.32-8
opensbi_0.4-1_all
linux-image-4.19.0-5-riscv64 4.19.37-4 third-party
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
(the repo is also used in mips target acceptance)
--- .travis.yml | 2 +- tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-)
.travis.yml +1 -1
@@ -232,7 +232,7 @@ matrix: # Acceptance (Functional) tests - env: - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" - TEST_CMD="make check-acceptance" after_failure: - cat tests/results/latest/job.log
tests/acceptance/boot_linux_console.py +66 -0
69 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 77 lines · Chih-Min Chao
Similar to the mips + malta test, it boots a Linux kernel on a virt board and verify the serial is working. Also, it relies on the serial device set by the machine itself.
If riscv64 is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:riscv64" tags.
Alternatively, this test can be run using:
$ avocado run -t arch:riscv64 tests/acceptancepackages
debian officialbinutils-riscv64-linux-gnu_2.32-8 opensbi_0.4-1_all linux-image-4.19.0-5-riscv64 4.19.37-4third-party
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
(the repo is also used in mips target acceptance)Signed-off-by Chih-Min Chao <[email protected]>--- .travis.yml | 2 +- tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-).travis.yml +1
-1@@ -232,7 +232,7 @@ matrix: # Acceptance (Functional) tests - env: - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" - TEST_CMD="make check-acceptance" after_failure: - cat tests/results/latest/job.logtests/acceptance/boot_linux_console.py +30
-0@@ -354,3 +354,69 @@ class BootLinuxConsole(Test): self.vm.launch() console_pattern = 'Kernel command line: %s' % kernel_command_line self.wait_for_console_pattern(console_pattern) + + def test_riscv64_virt(self): + """ + :avocado: tags=arch:riscv64 + :avocado: tags=machine:virt + """ + deb_url = ('https://snapshot.debian.org/archive/debian/' + '20190424T171759Z/pool/main/b/binutils/' + 'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' + objcopy_path = self.extract_from_deb(deb_path, objcopy_path) + libbfd_path = '/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so' + libbfd_path = self.extract_from_deb(deb_path, libbfd_path) + process.run('ls -al %s' % (objcopy_path)) + + deb_url = ('https://snapshot.debian.org/archive/debian/' + '20190708T032337Z/pool/main/o/opensbi/' + 'opensbi_0.4-1_all.deb') + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' + 'qemu/virt/fw_jump.elf') + opensbi_path = self.extract_from_deb(deb_path, opensbi_path) + + deb_url = ('https://snapshot.debian.org/archive/debian-ports/' + '20190620T095935Z/pool-riscv64/main/l/linux/' + 'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb') + deb_hash = ('bf5b5680c41d92134d22caef4fbd277c5217e1f0')
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 396
Quoted 10 lines
tests/acceptance/boot_linux_console.py +10
-0+ deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' + kernel_path = self.extract_from_deb(deb_path, kernel_path) + kimage_path = self.workdir + "/Image" + env = os.environ + env['LD_LIBRARY_PATH'] = ('%s:' % (os.path.dirname(libbfd_path)) + + env.get('LD_LIBRARY_PATH', '')) + process.run(('%s -O binary -O binary -R' + '.note -R .note.gnu.build-id -R .comment -S %s %s') % + (objcopy_path, kernel_path, kimage_path))
Please explain why you need to do that...
Also note these tests are run on other host architecture than x86, at least ppc64/s390x (so this won't work there).
Quoted 27 lines
tests/acceptance/boot_linux_console.py +26
-0+ + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' + '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/' + 'riscv64/rootfs.cpio.gz') + initrd_hash = 'f4867d263754961b6f626cdcdc0cb334c47e3b49' + initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) + + self.vm.set_machine('virt') + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0 noreboot') + self.vm.add_args('-bios', opensbi_path, + '-kernel', kimage_path, + '-initrd', initrd_path, + '-append', kernel_command_line, + '-no-reboot') + + self.vm.launch() + self.wait_for_console_pattern('Boot successful.') + + self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', + 'isa') + self.exec_command_and_wait_for_pattern('uname -a', + 'SMP Debian') + self.exec_command_and_wait_for_pattern('reboot', + 'reboot: Restarting system')
Quoted 96 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Chih-Min Chao
Similar to the mips + malta test, it boots a Linux kernel on a virt board and verify the serial is working. Also, it relies on the serial device set by the machine itself.
If riscv64 is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:riscv64" tags.
Alternatively, this test can be run using:
Quoted 9 lines
$ avocado run -t arch:riscv64 tests/acceptancepackages
debian officialbinutils-riscv64-linux-gnu_2.32-8 opensbi_0.4-1_all linux-image-4.19.0-5-riscv64 4.19.37-4third-party
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
Quoted 6 lines
(the repo is also used in mips target acceptance)
Signed-off-by Chih-Min Chao <[email protected]>--- .travis.yml | 2 +- tests/acceptance/boot_linux_console.py | 66++++++++++++++++++++++++++++++++++
.travis.yml matrix: · line 235
Quoted 11 lines
2 files changed, 67 insertions(+), 1 deletion(-).travis.yml +0
-1@@ -232,7 +232,7 @@ matrix: # Acceptance (Functional) tests - env: - - CONFIG="--python=/usr/bin/python3--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu"
.travis.yml matrix: · line 235
Quoted 1 line
.travis.yml +1
-0+ - CONFIG="--python=/usr/bin/python3--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu"
Review
Quoted 4 lines
.travis.yml +0
-0- TEST_CMD="make check-acceptance" after_failure: - cat tests/results/latest/job.log(quoted diff) +0
-0
b/tests/acceptance/boot_linux_console.pytests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 355
Quoted 6 lines
index 3215950..0f638bc 100644
tests/acceptance/boot_linux_console.py +0
-0@@ -354,3 +354,69 @@ class BootLinuxConsole(Test): self.vm.launch() console_pattern = 'Kernel command line: %s' %
kernel_command_lineQuoted 5 lines
tests/acceptance/boot_linux_console.py +4
-0self.wait_for_console_pattern(console_pattern) + + def test_riscv64_virt(self): + """ + :avocado: tags=arch:riscv64tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 10 lines
tests/acceptance/boot_linux_console.py +10
-0+ :avocado: tags=machine:virt + """ + deb_url = ('https://snapshot.debian.org/archive/debian/' + '20190424T171759Z/pool/main/b/binutils/' + 'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' + objcopy_path = self.extract_from_deb(deb_path, objcopy_path) + libbfd_path = '/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so'
Quoted 12 lines
tests/acceptance/boot_linux_console.py +12
-0+ libbfd_path = self.extract_from_deb(deb_path, libbfd_path) + process.run('ls -al %s' % (objcopy_path)) + + deb_url = ('https://snapshot.debian.org/archive/debian/' + '20190708T032337Z/pool/main/o/opensbi/' + 'opensbi_0.4-1_all.deb') + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' + 'qemu/virt/fw_jump.elf') + opensbi_path = self.extract_from_deb(deb_path, opensbi_path) +tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 10 lines
tests/acceptance/boot_linux_console.py +10
-0+ deb_url = ('https://snapshot.debian.org/archive/debian-ports/' + '20190620T095935Z/pool-riscv64/main/l/linux/' + 'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb') + deb_hash = ('bf5b5680c41d92134d22caef4fbd277c5217e1f0') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' + kernel_path = self.extract_from_deb(deb_path, kernel_path) + kimage_path = self.workdir + "/Image" + env = os.environ + env['LD_LIBRARY_PATH'] = ('%s:' %(
os.path.dirname(libbfd_path)) +tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 3 lines
tests/acceptance/boot_linux_console.py +3
-0+ env.get('LD_LIBRARY_PATH', '')) + process.run(('%s -O binary -O binary -R' + '.note -R .note.gnu.build-id -R .comment -S %s%s') %
Quoted 8 lines
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 396
Quoted 1 line
tests/acceptance/boot_linux_console.py +1
-0+ (objcopy_path, kernel_path, kimage_path))Please explain why you need to do that...
Also note these tests are run on other host architecture than x86, at least ppc64/s390x (so this won't work there).
it is because riscv64 vmlinux doesn't have physical loading address
information and
depends on certain stage bootloader to move kernel raw data to specific physical address (0x8020_0000)
The vmlinux program headers are
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD 0x001000 0xffffffe000000000 0x0000000000000000 0x0303a60x0303a6 R E 0x1000
LOAD 0x032000 0xffffffe000031000 0x0000000000031000 0x828f0c0x828f0c RWE 0x1000
NOTE 0x85aec0 0xffffffe000859ec0 0x0000000000859ec0 0x00004c0x00004c R 0x4
For legacy bootloader, bbl, It can handle payload in ELF format. However, for the newer OpenSBI, it can only handle raw data and
debian doesn't provide linux image in raw data format.
Quoted 30 lines
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 6 lines
tests/acceptance/boot_linux_console.py +6
-0+ + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' + '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/' + 'riscv64/rootfs.cpio.gz') + initrd_hash = 'f4867d263754961b6f626cdcdc0cb334c47e3b49' + initrd_path = self.fetch_asset(initrd_url,asset_hash=initrd_hash)
Quoted 10 lines
tests/acceptance/boot_linux_console.py +10
-0+ + self.vm.set_machine('virt') + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0 noreboot') + self.vm.add_args('-bios', opensbi_path, + '-kernel', kimage_path, + '-initrd', initrd_path, + '-append', kernel_command_line, + '-no-reboot')tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 10 lines
tests/acceptance/boot_linux_console.py +10
-0+ + self.vm.launch() + self.wait_for_console_pattern('Boot successful.') + + self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', + 'isa') + self.exec_command_and_wait_for_pattern('uname -a', + 'SMP Debian') + self.exec_command_and_wait_for_pattern('reboot', + 'reboot: Restartingsystem')
Quoted 1 line
Quoted 126 lines · Chih-Min Chao
On Mon, Jul 15, 2019 at 5:15 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 7/15/19 11:08 AM, Chih-Min Chao wrote:
> Similar to the mips + malta test, it boots a Linux kernel on a virt
> board and verify the serial is working. Also, it relies on the serial
> device set by the machine itself.
>
> If riscv64 is a target being built, "make check-acceptance" will
> automatically include this test by the use of the "arch:riscv64" tags.
>
> Alternatively, this test can be run using:
>
> $ avocado run -t arch:riscv64 tests/acceptance
>
> packages
> debian official
> binutils-riscv64-linux-gnu_2.32-8
> opensbi_0.4-1_all
> linux-image-4.19.0-5-riscv64 4.19.37-4
> third-party
>
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
> (the repo is also used in mips target acceptance)
>
> Signed-off-by: Chih-Min Chao <[email protected]
<mailto:[email protected]>>
> ---
> .travis.yml | 2 +-
>tests/acceptance/boot_linux_console.py| 66
++++++++++++++++++++++++++++++++++
> 2 files changed, 67 insertions(+), 1 deletion(-)
>
> diff --gita/.travis.ymlb/.travis.yml
> index 5d3d6ee..21fcead 100644
> ---a/.travis.yml
> +++b/.travis.yml
> @@ -232,7 +232,7 @@ matrix:
>
> # Acceptance (Functional) tests
> - env:
> - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" > + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" > - TEST_CMD="make check-acceptance"
>after_failure:
> - cat tests/results/latest/job.log
> diff --gita/tests/acceptance/boot_linux_console.py
b/tests/acceptance/boot_linux_console.py
> index 3215950..0f638bc 100644
> ---a/tests/acceptance/boot_linux_console.py
> +++b/tests/acceptance/boot_linux_console.py
> @@ -354,3 +354,69 @@ class BootLinuxConsole(Test):
>self.vm.launch()
>console_pattern= 'Kernel command line: %s' %
kernel_command_line
>self.wait_for_console_pattern(console_pattern)
> +
> + deftest_riscv64_virt(self):
> + """
> + :avocado: tags=arch:riscv64
> + :avocado: tags=machine:virt
> + """
> +deb_url= ('https://snapshot.debian.org/archive/debian/'
> + '20190424T171759Z/pool/main/b/binutils/'
> +
'binutils-riscv64-linux-gnu_2.32-8_amd64.deb')
> +deb_hash= ('7fe376fd4452696c03acd508d6d613ca553ea15e')
> +deb_path=self.fetch_asset(deb_url, asset_hash=deb_hash)
> +objcopy_path= '/usr/bin/riscv64-linux-gnu-objcopy'
> +objcopy_path=self.extract_from_deb(deb_path, objcopy_path)
> +libbfd_path=
'/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so
<http://libbfd-2.32-riscv64.so>'
> +libbfd_path=self.extract_from_deb(deb_path, libbfd_path)
> +process.run('ls -al %s' % (objcopy_path))
> +
> +deb_url= ('https://snapshot.debian.org/archive/debian/'
> + '20190708T032337Z/pool/main/o/opensbi/'
> + 'opensbi_0.4-1_all.deb')
> +deb_hash= ('2319dcd702958291d323acf5649fd98a11d90112')
> +deb_path=self.fetch_asset(deb_url, asset_hash=deb_hash)
> +opensbi_path= ('/usr/lib/riscv64-linux-gnu/opensbi/'
> + 'qemu/virt/fw_jump.elf')
> +opensbi_path=self.extract_from_deb(deb_path, opensbi_path)
> +
> +deb_url=
('https://snapshot.debian.org/archive/debian-ports/'
> + '20190620T095935Z/pool-riscv64/main/l/linux/'
> +
'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb')
> +deb_hash= ('bf5b5680c41d92134d22caef4fbd277c5217e1f0')
> +deb_path=self.fetch_asset(deb_url, asset_hash=deb_hash)
> +kernel_path= '/boot/vmlinux-4.19.0-5-riscv64'
> +kernel_path=self.extract_from_deb(deb_path, kernel_path)
> +kimage_path= self.workdir + "/Image"
> + env = os.environ
> + env['LD_LIBRARY_PATH'] = ('%s:' %
(os.path.dirname(libbfd_path)) +
> + env.get('LD_LIBRARY_PATH', ''))
> + process.run(('%s -O binary -O binary -R'
> + '.note -R .note.gnu.build-id -R .comment -S
%s %s') %
> + (objcopy_path,kernel_path,kimage_path))Please explain why you need to do that...
Also note these tests are run on other host architecture than x86, at least ppc64/s390x (so this won't work there).
it is because riscv64 vmlinux doesn't have physical loading address information and
depends on certain stage bootloader to move kernel raw data to specific physical address (0x8020_0000)The vmlinux program headers are
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD0x0010000xffffffe0000000000x00000000000000000x0303a60x0303a6R E0x1000
LOAD0x0320000xffffffe0000310000x00000000000310000x828f0c0x828f0cRWE0x1000
NOTE0x85aec00xffffffe000859ec00x0000000000859ec00x00004c0x00004cR0x4
Quoted 3 lines
For legacy bootloader, bbl, It can handle payload in ELF format. However, for the newer OpenSBI, it can only handle raw data and debian doesn't provide linux image in raw data format.
I think you should be able to use -device loader,file=... here, then no need to use objcopy.
Cc'ing Alistair who is an expert on this.
Quoted 32 lines
Quoted 2 lines
+
+initrd_url=('https://github.com/groeck/linux-build-test/raw/'
> +
'8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
> + 'riscv64/rootfs.cpio.gz')
> +initrd_hash= 'f4867d263754961b6f626cdcdc0cb334c47e3b49' > +initrd_path=self.fetch_asset(initrd_url, asset_hash=initrd_hash)
> +
> +self.vm.set_machine('virt')
> +self.vm.set_console()
> +kernel_command_line= (self.KERNEL_COMMON_COMMAND_LINE > + + 'console=ttyS0 noreboot') > + self.vm.add_args('-bios',opensbi_path,
> + '-kernel',kimage_path,
> + '-initrd',initrd_path,
> + '-append',kernel_command_line, > + '-no-reboot')
> +
> +self.vm.launch()
> +self.wait_for_console_pattern('Boot successful.')> +
> + self.exec_command_and_wait_for_pattern('cat/proc/cpuinfo', > + 'isa')
> +self.exec_command_and_wait_for_pattern('uname -a', > + 'SMP Debian')> + self.exec_command_and_wait_for_pattern('reboot', > + 'reboot:
Restarting system')
>
Quoted 128 lines · Philippe Mathieu-Daudé
Quoted 126 lines · Chih-Min Chao
On Mon, Jul 15, 2019 at 5:15 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 7/15/19 11:08 AM, Chih-Min Chao wrote: > Similar to the mips + malta test, it boots a Linux kernel on a virt > board and verify the serial is working. Also, it relies on the serial > device set by the machine itself. > > If riscv64 is a target being built, "make check-acceptance" will > automatically include this test by the use of the "arch:riscv64" tags. > > Alternatively, this test can be run using: > > $ avocado run -t arch:riscv64 tests/acceptance > > packages > debian official > binutils-riscv64-linux-gnu_2.32-8 > opensbi_0.4-1_all > linux-image-4.19.0-5-riscv64 4.19.37-4 > third-party > https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz > (the repo is also used in mips target acceptance) > > Signed-off-by: Chih-Min Chao <[email protected] <mailto:[email protected]>> > --- > .travis.yml | 2 +- > tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ > 2 files changed, 67 insertions(+), 1 deletion(-) > > diff --git a/.travis.yml b/.travis.yml > index 5d3d6ee..21fcead 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -232,7 +232,7 @@ matrix: > > # Acceptance (Functional) tests > - env: > - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" > + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" > - TEST_CMD="make check-acceptance" > after_failure: > - cat tests/results/latest/job.log > diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py > index 3215950..0f638bc 100644 > --- a/tests/acceptance/boot_linux_console.py > +++ b/tests/acceptance/boot_linux_console.py > @@ -354,3 +354,69 @@ class BootLinuxConsole(Test): > self.vm.launch() > console_pattern = 'Kernel command line: %s' % kernel_command_line > self.wait_for_console_pattern(console_pattern) > + > + def test_riscv64_virt(self): > + """ > + :avocado: tags=arch:riscv64 > + :avocado: tags=machine:virt > + """ > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190424T171759Z/pool/main/b/binutils/' > + 'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') > + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' > + objcopy_path = self.extract_from_deb(deb_path, objcopy_path) > + libbfd_path = '/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so <http://libbfd-2.32-riscv64.so>' > + libbfd_path = self.extract_from_deb(deb_path, libbfd_path) > + process.run('ls -al %s' % (objcopy_path)) > + > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190708T032337Z/pool/main/o/opensbi/' > + 'opensbi_0.4-1_all.deb') > + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' > + 'qemu/virt/fw_jump.elf') > + opensbi_path = self.extract_from_deb(deb_path, opensbi_path) > + > + deb_url = ('https://snapshot.debian.org/archive/debian-ports/' > + '20190620T095935Z/pool-riscv64/main/l/linux/' > + 'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb') > + deb_hash = ('bf5b5680c41d92134d22caef4fbd277c5217e1f0') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' > + kernel_path = self.extract_from_deb(deb_path, kernel_path) > + kimage_path = self.workdir + "/Image" > + env = os.environ > + env['LD_LIBRARY_PATH'] = ('%s:' % (os.path.dirname(libbfd_path)) + > + env.get('LD_LIBRARY_PATH', '')) > + process.run(('%s -O binary -O binary -R' > + '.note -R .note.gnu.build-id -R .comment -S %s %s') % > + (objcopy_path, kernel_path, kimage_path)) Please explain why you need to do that... Also note these tests are run on other host architecture than x86, at least ppc64/s390x (so this won't work there).it is because riscv64 vmlinux doesn't have physical loading address information and
depends on certain stage bootloader to move kernel raw data to specific physical address (0x8020_0000)The vmlinux program headers are
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD0x0010000xffffffe0000000000x00000000000000000x0303a60x0303a6R E0x1000
LOAD0x0320000xffffffe0000310000x00000000000310000x828f0c0x828f0cRWE0x1000
NOTE0x85aec00xffffffe000859ec00x0000000000859ec00x00004c0x00004cR0x4
Quoted 3 lines
Quoted 3 lines
For legacy bootloader, bbl, It can handle payload in ELF format. However, for the newer OpenSBI, it can only handle raw data and debian doesn't provide linux image in raw data format.
This doesn't sound right. You should just be able to say -kernel <anything> and it should work. It has worked for me with vmlinux and Image files when using master (not the 4.0 release but master/4.1). Although all of my testing was with the 5.1 kernel, so maybe there is a difference there?
What isn't working for you? Can you include the errors and output of -d in_asm?
Alistair
Quoted 39 lines
I think you should be able to use -device loader,file=... here, then no need to use objcopy.
Cc'ing Alistair who is an expert on this.
Quoted 32 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + initrd_url =('https://github.com/groeck/linux-build-test/raw/' > + '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
> + 'riscv64/rootfs.cpio.gz')
> +initrd_hash= 'f4867d263754961b6f626cdcdc0cb334c47e3b49'
> +initrd_path= self.fetch_asset(initrd_url,
asset_hash=initrd_hash)
> +
> +self.vm.set_machine('virt')
> +self.vm.set_console()
> +kernel_command_line= (self.KERNEL_COMMON_COMMAND_LINE
> + + 'console=ttyS0 noreboot')
> + self.vm.add_args('-bios',opensbi_path,
> + '-kernel',kimage_path,
> + '-initrd',initrd_path,
> + '-append',kernel_command_line,
> + '-no-reboot')
> +
> +self.vm.launch()
> +self.wait_for_console_pattern('Boot successful.')
> +
> + self.exec_command_and_wait_for_pattern('cat/proc/cpuinfo',
> + 'isa')
> + self.exec_command_and_wait_for_pattern('uname -a',
> + 'SMP Debian')
> + self.exec_command_and_wait_for_pattern('reboot',
> + 'reboot:
Restarting system')
>
Quoted 160 lines · Alistair Francis
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Chih-Min Chao
On Mon, Jul 15, 2019 at 5:15 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 7/15/19 11:08 AM, Chih-Min Chao wrote:
> Similar to the mips + malta test, it boots a Linux kernel on avirt
Quoted 1 line
Quoted 1 line
Quoted 1 line
board and verify the serial is working. Also, it relies on the
serial
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
device set by the machine itself.
If riscv64 is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:riscv64"
tags.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Alternatively, this test can be run using:
$ avocado run -t arch:riscv64 tests/acceptanceQuoted 8 lines
Quoted 8 lines
Quoted 7 lines
packages
debian officialbinutils-riscv64-linux-gnu_2.32-8 opensbi_0.4-1_all linux-image-4.19.0-5-riscv64 4.19.37-4third-party
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
Quoted 16 lines
Quoted 16 lines
Quoted 3 lines
(the repo is also used in mips target acceptance)
Signed-off-by Chih-Min Chao <[email protected]<mailto:[email protected]>> > --- > .travis.yml | 2 +- > tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ > 2 files changed, 67 insertions(+), 1 deletion(-) > > diff --git a/.travis.yml b/.travis.yml > index 5d3d6ee..21fcead 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -232,7 +232,7 @@ matrix: >Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
# Acceptance (Functional) tests
- env:
- - CONFIG="--python=/usr/bin/python3--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu"
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
+ - CONFIG="--python=/usr/bin/python3
--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu"
Quoted 12 lines
Quoted 12 lines
Review
Quoted 4 lines
- TEST_CMD="make check-acceptance"
after_failure:
- cat tests/results/latest/job.log(quoted diff) +0
-0
b/tests/acceptance/boot_linux_console.py
> index 3215950..0f638bc 100644
> ---a/tests/acceptance/boot_linux_console.py> +++b/tests/acceptance/boot_linux_console.py> @@ -354,3 +354,69 @@ class BootLinuxConsole(Test):
>self.vm.launch()
>console_pattern= 'Kernel command line: %s' %
kernel_command_lineQuoted 8 lines
Quoted 8 lines
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 8 lines
self.wait_for_console_pattern(console_pattern)tests/acceptance/boot_linux_console.py +7
-0+ + def test_riscv64_virt(self): + """ + :avocado: tags=arch:riscv64 + :avocado: tags=machine:virt + """ + deb_url = ('https://snapshot.debian.org/archive/debian/'
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
'20190424T171759Z/pool/main/b/binutils/'
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+
'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') > + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') > + deb_path = self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' + objcopy_path = self.extract_from_deb(deb_path,
objcopy_path)Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+
libbfd_path='/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so <http://libbfd-2.32-riscv64.so>' > + libbfd_path = self.extract_from_deb(deb_path,
libbfd_path)Quoted 3 lines
Quoted 3 lines
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 3 lines
tests/acceptance/boot_linux_console.py +3
-0+ process.run('ls -al %s' % (objcopy_path)) + + deb_url = ('https://snapshot.debian.org/archive/debian/'
Quoted 4 lines
Quoted 4 lines
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 4 lines
tests/acceptance/boot_linux_console.py +4
-0+ '20190708T032337Z/pool/main/o/opensbi/' + 'opensbi_0.4-1_all.deb') + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') + deb_path = self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 3 lines
Quoted 3 lines
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 3 lines
tests/acceptance/boot_linux_console.py +3
-0+ opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' + 'qemu/virt/fw_jump.elf') + opensbi_path = self.extract_from_deb(deb_path,
opensbi_path)Quoted 8 lines
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + deb_url =('https://snapshot.debian.org/archive/debian-ports/' > + '20190620T095935Z/pool-riscv64/main/l/linux/' > + 'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb') > + deb_hash = ('bf5b5680c41d92134d22caef4fbd277c5217e1f0') > + deb_path = self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' + kernel_path = self.extract_from_deb(deb_path,
kernel_path)Quoted 10 lines
Quoted 10 lines
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 3 lines
tests/acceptance/boot_linux_console.py +3
-0+ kimage_path = self.workdir + "/Image" + env = os.environ + env['LD_LIBRARY_PATH'] = ('%s:' %(
os.path.dirname(libbfd_path)) +
> +env.get('LD_LIBRARY_PATH', ''))
> + process.run(('%s -O binary -O binary -R'
> + '.note -R .note.gnu.build-id -R .comment -S
%s %s') %
> + (objcopy_path,kernel_path,kimage_path))Quoted 3 lines
Quoted 3 lines
Please explain why you need to do that...
Also note these tests are run on other host architecture than x86,
at
Quoted 11 lines
Quoted 11 lines
least ppc64/s390x (so this won't work there).it is because riscv64 vmlinux doesn't have physical loading address information and
depends on certain stage bootloader to move kernel raw data to specific physical address (0x8020_0000)The vmlinux program headers are
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD0x0010000xffffffe0000000000x0000000000000000
0x0303a6Quoted 2 lines
Quoted 2 lines
0x0303a6R E0x1000
LOAD0x0320000xffffffe0000310000x0000000000031000
0x828f0cQuoted 2 lines
Quoted 2 lines
0x828f0cRWE0x1000
NOTE0x85aec00xffffffe000859ec00x0000000000859ec0
0x00004cQuoted 5 lines
Quoted 5 lines
0x00004cR0x4For legacy bootloader, bbl, It can handle payload in ELF format. However, for the newer OpenSBI, it can only handle raw data and debian doesn't provide linux image in raw data format.
This doesn't sound right. You should just be able to say -kernel <anything> and it should work. It has worked for me with vmlinux and Image files when using master (not the 4.0 release but master/4.1). Although all of my testing was with the 5.1 kernel, so maybe there is a difference there?
Quoted 6 lines
What isn't working for you? Can you include the errors and output of -d
in_asm?Alistair
Hi Alistair,
I have come across error before starting target simulation. What I
means is to execute
qemu-system-riscv64 -M virt -m 256M -nographic -bios
./opensbi/build/platform/qemu/virt/firmware/fw_jump.elf -kernel vmlinux
then get the error message
rom: requested regions overlap (rom mrom.reset.
free=0x000000000001eb7c, addr=0x0000000000001000)
qemu-system-riscv64: rom check and register reset failed
chihmin.chao
Quoted 41 lines
Quoted 30 lines
I think you should be able to use -device loader,file=... here, then no need to use objcopy.
Cc'ing Alistair who is an expert on this.
Quoted 24 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + initrd_url =('https://github.com/groeck/linux-build-test/raw/' > + '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
> + 'riscv64/rootfs.cpio.gz')
> +initrd_hash= 'f4867d263754961b6f626cdcdc0cb334c47e3b49'
> +initrd_path= self.fetch_asset(initrd_url,
asset_hash=initrd_hash)
> +
> +self.vm.set_machine('virt')
> +self.vm.set_console()
> +kernel_command_line= (self.KERNEL_COMMON_COMMAND_LINE
> + + 'console=ttyS0 noreboot')
> + self.vm.add_args('-bios',opensbi_path,
> + '-kernel',kimage_path,
> + '-initrd',initrd_path,
> + '-append',kernel_command_line,
> + '-no-reboot')
> +
> +self.vm.launch()
> +self.wait_for_console_pattern('Boot successful.')
> +
> + self.exec_command_and_wait_for_pattern('cat
/proc/cpuinfo',Quoted 9 lines
Quoted 8 lines
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 5 lines
tests/acceptance/boot_linux_console.py +5
-0+ 'isa') + self.exec_command_and_wait_for_pattern('uname -a', + 'SMP Debian') + self.exec_command_and_wait_for_pattern('reboot', + 'reboot:Restarting system') >
Quoted 150 lines · Chih-Min Chao
Quoted 141 lines · Alistair Francis
Quoted 128 lines · Philippe Mathieu-Daudé
Quoted 126 lines · Chih-Min Chao
On Mon, Jul 15, 2019 at 5:15 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 7/15/19 11:08 AM, Chih-Min Chao wrote: > Similar to the mips + malta test, it boots a Linux kernel on a virt > board and verify the serial is working. Also, it relies on the serial > device set by the machine itself. > > If riscv64 is a target being built, "make check-acceptance" will > automatically include this test by the use of the "arch:riscv64" tags. > > Alternatively, this test can be run using: > > $ avocado run -t arch:riscv64 tests/acceptance > > packages > debian official > binutils-riscv64-linux-gnu_2.32-8 > opensbi_0.4-1_all > linux-image-4.19.0-5-riscv64 4.19.37-4 > third-party > https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz > (the repo is also used in mips target acceptance) > > Signed-off-by: Chih-Min Chao <[email protected] <mailto:[email protected]>> > --- > .travis.yml | 2 +- > tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ > 2 files changed, 67 insertions(+), 1 deletion(-) > > diff --git a/.travis.yml b/.travis.yml > index 5d3d6ee..21fcead 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -232,7 +232,7 @@ matrix: > > # Acceptance (Functional) tests > - env: > - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" > + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" > - TEST_CMD="make check-acceptance" > after_failure: > - cat tests/results/latest/job.log > diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py > index 3215950..0f638bc 100644 > --- a/tests/acceptance/boot_linux_console.py > +++ b/tests/acceptance/boot_linux_console.py > @@ -354,3 +354,69 @@ class BootLinuxConsole(Test): > self.vm.launch() > console_pattern = 'Kernel command line: %s' % kernel_command_line > self.wait_for_console_pattern(console_pattern) > + > + def test_riscv64_virt(self): > + """ > + :avocado: tags=arch:riscv64 > + :avocado: tags=machine:virt > + """ > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190424T171759Z/pool/main/b/binutils/' > + 'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') > + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' > + objcopy_path = self.extract_from_deb(deb_path, objcopy_path) > + libbfd_path = '/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so <http://libbfd-2.32-riscv64.so>' > + libbfd_path = self.extract_from_deb(deb_path, libbfd_path) > + process.run('ls -al %s' % (objcopy_path)) > + > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190708T032337Z/pool/main/o/opensbi/' > + 'opensbi_0.4-1_all.deb') > + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' > + 'qemu/virt/fw_jump.elf') > + opensbi_path = self.extract_from_deb(deb_path, opensbi_path) > + > + deb_url = ('https://snapshot.debian.org/archive/debian-ports/' > + '20190620T095935Z/pool-riscv64/main/l/linux/' > + 'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb') > + deb_hash = ('bf5b5680c41d92134d22caef4fbd277c5217e1f0') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' > + kernel_path = self.extract_from_deb(deb_path, kernel_path) > + kimage_path = self.workdir + "/Image" > + env = os.environ > + env['LD_LIBRARY_PATH'] = ('%s:' % (os.path.dirname(libbfd_path)) + > + env.get('LD_LIBRARY_PATH', '')) > + process.run(('%s -O binary -O binary -R' > + '.note -R .note.gnu.build-id -R .comment -S %s %s') % > + (objcopy_path, kernel_path, kimage_path)) Please explain why you need to do that... Also note these tests are run on other host architecture than x86, at least ppc64/s390x (so this won't work there).it is because riscv64 vmlinux doesn't have physical loading address information and
depends on certain stage bootloader to move kernel raw data to specific physical address (0x8020_0000)The vmlinux program headers are
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD0x0010000xffffffe0000000000x00000000000000000x0303a60x0303a6R E0x1000
LOAD0x0320000xffffffe0000310000x00000000000310000x828f0c0x828f0cRWE0x1000
NOTE0x85aec00xffffffe000859ec00x0000000000859ec00x00004c0x00004cR0x4Quoted 3 lines
Quoted 3 lines
For legacy bootloader, bbl, It can handle payload in ELF format. However, for the newer OpenSBI, it can only handle raw data and debian doesn't provide linux image in raw data format.
This doesn't sound right. You should just be able to say -kernel <anything> and it should work. It has worked for me with vmlinux and Image files when using master (not the 4.0 release but master/4.1). Although all of my testing was with the 5.1 kernel, so maybe there is a difference there?
Quoted 4 lines
What isn't working for you? Can you include the errors and output of -d
in_asm?Alistair
Quoted 6 lines
Hi Alistair,
I have come across error before starting target simulation. What I means is to execute
qemu-system-riscv64 -M virt -m 256M -nographic -bios ./opensbi/build/platform/qemu/virt/firmware/fw_jump.elf -kernel vmlinux
then get the error message
rom: requested regions overlap (rom mrom.reset. free=0x000000000001eb7c, addr=0x0000000000001000)
qemu-system-riscv64: rom check and register reset failed
Hmmm.... I don't remember seeing this problem in my testing, but it does seem to make sense.
We have two options here:
1. Use the Image file from Linux 5.0+ (my preferred option as 4.19 is getting old)
2. Use the device loader (documented here:
https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md)
Alistair
Quoted 158 lines · Alistair Francis
Quoted 150 lines · Chih-Min Chao
Quoted 141 lines · Alistair Francis
Quoted 128 lines · Philippe Mathieu-Daudé
Quoted 126 lines · Chih-Min Chao
On Mon, Jul 15, 2019 at 5:15 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 7/15/19 11:08 AM, Chih-Min Chao wrote: > Similar to the mips + malta test, it boots a Linux kernel on a virt > board and verify the serial is working. Also, it relies on the serial > device set by the machine itself. > > If riscv64 is a target being built, "make check-acceptance" will > automatically include this test by the use of the "arch:riscv64" tags. > > Alternatively, this test can be run using: > > $ avocado run -t arch:riscv64 tests/acceptance > > packages > debian official > binutils-riscv64-linux-gnu_2.32-8 > opensbi_0.4-1_all > linux-image-4.19.0-5-riscv64 4.19.37-4 > third-party > https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz > (the repo is also used in mips target acceptance) > > Signed-off-by: Chih-Min Chao <[email protected] <mailto:[email protected]>> > --- > .travis.yml | 2 +- > tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ > 2 files changed, 67 insertions(+), 1 deletion(-) > > diff --git a/.travis.yml b/.travis.yml > index 5d3d6ee..21fcead 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -232,7 +232,7 @@ matrix: > > # Acceptance (Functional) tests > - env: > - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" > + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" > - TEST_CMD="make check-acceptance" > after_failure: > - cat tests/results/latest/job.log > diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py > index 3215950..0f638bc 100644 > --- a/tests/acceptance/boot_linux_console.py > +++ b/tests/acceptance/boot_linux_console.py > @@ -354,3 +354,69 @@ class BootLinuxConsole(Test): > self.vm.launch() > console_pattern = 'Kernel command line: %s' % kernel_command_line > self.wait_for_console_pattern(console_pattern) > + > + def test_riscv64_virt(self): > + """ > + :avocado: tags=arch:riscv64 > + :avocado: tags=machine:virt > + """ > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190424T171759Z/pool/main/b/binutils/' > + 'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') > + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' > + objcopy_path = self.extract_from_deb(deb_path, objcopy_path) > + libbfd_path = '/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so <http://libbfd-2.32-riscv64.so>' > + libbfd_path = self.extract_from_deb(deb_path, libbfd_path) > + process.run('ls -al %s' % (objcopy_path)) > + > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190708T032337Z/pool/main/o/opensbi/' > + 'opensbi_0.4-1_all.deb') > + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' > + 'qemu/virt/fw_jump.elf') > + opensbi_path = self.extract_from_deb(deb_path, opensbi_path) > + > + deb_url = ('https://snapshot.debian.org/archive/debian-ports/' > + '20190620T095935Z/pool-riscv64/main/l/linux/' > + 'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb') > + deb_hash = ('bf5b5680c41d92134d22caef4fbd277c5217e1f0') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' > + kernel_path = self.extract_from_deb(deb_path, kernel_path) > + kimage_path = self.workdir + "/Image" > + env = os.environ > + env['LD_LIBRARY_PATH'] = ('%s:' % (os.path.dirname(libbfd_path)) + > + env.get('LD_LIBRARY_PATH', '')) > + process.run(('%s -O binary -O binary -R' > + '.note -R .note.gnu.build-id -R .comment -S %s %s') % > + (objcopy_path, kernel_path, kimage_path)) Please explain why you need to do that... Also note these tests are run on other host architecture than x86, at least ppc64/s390x (so this won't work there).it is because riscv64 vmlinux doesn't have physical loading address information and
depends on certain stage bootloader to move kernel raw data to specific physical address (0x8020_0000)The vmlinux program headers are
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD0x0010000xffffffe0000000000x00000000000000000x0303a60x0303a6R E0x1000
LOAD0x0320000xffffffe0000310000x00000000000310000x828f0c0x828f0cRWE0x1000
NOTE0x85aec00xffffffe000859ec00x0000000000859ec00x00004c0x00004cR0x4Quoted 3 lines
Quoted 3 lines
For legacy bootloader, bbl, It can handle payload in ELF format. However, for the newer OpenSBI, it can only handle raw data and debian doesn't provide linux image in raw data format.
This doesn't sound right. You should just be able to say -kernel <anything> and it should work. It has worked for me with vmlinux and Image files when using master (not the 4.0 release but master/4.1). Although all of my testing was with the 5.1 kernel, so maybe there is a difference there?
Quoted 4 lines
What isn't working for you? Can you include the errors and output of -d
in_asm?Alistair
Quoted 6 lines
Hi Alistair,
I have come across error before starting target simulation. What I means is to execute
qemu-system-riscv64 -M virt -m 256M -nographic -bios ./opensbi/build/platform/qemu/virt/firmware/fw_jump.elf -kernel vmlinux
then get the error message
rom: requested regions overlap (rom mrom.reset. free=0x000000000001eb7c, addr=0x0000000000001000)
qemu-system-riscv64: rom check and register reset failed
Quoted 8 lines
Hmmm.... I don't remember seeing this problem in my testing, but it does seem to make sense.
We have two options here:
1. Use the Image file from Linux 5.0+ (my preferred option as 4.19 is getting old)
2. Use the device loader (documented here:
https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md)
Nice doc, this example is exactly what I had in mind:
qemu-system-riscv64 -M virt -m 256M -nographic \ -kernel build/platform/qemu/virt/firmware/fw_jump.elf \ -device loader,file=<linux_build_directory>/arch/riscv/boot/Image,addr=0x80200000 \ -drive file=<path_to_linux_rootfs>,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -append "root=/dev/vda rw console=ttyS0"
If the Image is an ELF, I assume we don't need to specify the address, because the device loader knows how to parse this format. Again, Alistair is the expert ;)
If for some reason it only works with Linux 5.0+, let's use these!
Regards,
Phil.
Quoted 179 lines · Philippe Mathieu-Daudé
Quoted 158 lines · Alistair Francis
Quoted 150 lines · Chih-Min Chao
Quoted 141 lines · Alistair Francis
Quoted 128 lines · Philippe Mathieu-Daudé
Quoted 126 lines · Chih-Min Chao
On Mon, Jul 15, 2019 at 5:15 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 7/15/19 11:08 AM, Chih-Min Chao wrote: > Similar to the mips + malta test, it boots a Linux kernel on a virt > board and verify the serial is working. Also, it relies on the serial > device set by the machine itself. > > If riscv64 is a target being built, "make check-acceptance" will > automatically include this test by the use of the "arch:riscv64" tags. > > Alternatively, this test can be run using: > > $ avocado run -t arch:riscv64 tests/acceptance > > packages > debian official > binutils-riscv64-linux-gnu_2.32-8 > opensbi_0.4-1_all > linux-image-4.19.0-5-riscv64 4.19.37-4 > third-party > https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz > (the repo is also used in mips target acceptance) > > Signed-off-by: Chih-Min Chao <[email protected] <mailto:[email protected]>> > --- > .travis.yml | 2 +- > tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ > 2 files changed, 67 insertions(+), 1 deletion(-) > > diff --git a/.travis.yml b/.travis.yml > index 5d3d6ee..21fcead 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -232,7 +232,7 @@ matrix: > > # Acceptance (Functional) tests > - env: > - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" > + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" > - TEST_CMD="make check-acceptance" > after_failure: > - cat tests/results/latest/job.log > diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py > index 3215950..0f638bc 100644 > --- a/tests/acceptance/boot_linux_console.py > +++ b/tests/acceptance/boot_linux_console.py > @@ -354,3 +354,69 @@ class BootLinuxConsole(Test): > self.vm.launch() > console_pattern = 'Kernel command line: %s' % kernel_command_line > self.wait_for_console_pattern(console_pattern) > + > + def test_riscv64_virt(self): > + """ > + :avocado: tags=arch:riscv64 > + :avocado: tags=machine:virt > + """ > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190424T171759Z/pool/main/b/binutils/' > + 'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') > + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' > + objcopy_path = self.extract_from_deb(deb_path, objcopy_path) > + libbfd_path = '/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so <http://libbfd-2.32-riscv64.so>' > + libbfd_path = self.extract_from_deb(deb_path, libbfd_path) > + process.run('ls -al %s' % (objcopy_path)) > + > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190708T032337Z/pool/main/o/opensbi/' > + 'opensbi_0.4-1_all.deb') > + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' > + 'qemu/virt/fw_jump.elf') > + opensbi_path = self.extract_from_deb(deb_path, opensbi_path) > + > + deb_url = ('https://snapshot.debian.org/archive/debian-ports/' > + '20190620T095935Z/pool-riscv64/main/l/linux/' > + 'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb') > + deb_hash = ('bf5b5680c41d92134d22caef4fbd277c5217e1f0') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' > + kernel_path = self.extract_from_deb(deb_path, kernel_path) > + kimage_path = self.workdir + "/Image" > + env = os.environ > + env['LD_LIBRARY_PATH'] = ('%s:' % (os.path.dirname(libbfd_path)) + > + env.get('LD_LIBRARY_PATH', '')) > + process.run(('%s -O binary -O binary -R' > + '.note -R .note.gnu.build-id -R .comment -S %s %s') % > + (objcopy_path, kernel_path, kimage_path)) Please explain why you need to do that... Also note these tests are run on other host architecture than x86, at least ppc64/s390x (so this won't work there).it is because riscv64 vmlinux doesn't have physical loading address information and
depends on certain stage bootloader to move kernel raw data to specific physical address (0x8020_0000)The vmlinux program headers are
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD0x0010000xffffffe0000000000x00000000000000000x0303a60x0303a6R E0x1000
LOAD0x0320000xffffffe0000310000x00000000000310000x828f0c0x828f0cRWE0x1000
NOTE0x85aec00xffffffe000859ec00x0000000000859ec00x00004c0x00004cR0x4Quoted 3 lines
Quoted 3 lines
For legacy bootloader, bbl, It can handle payload in ELF format. However, for the newer OpenSBI, it can only handle raw data and debian doesn't provide linux image in raw data format.
This doesn't sound right. You should just be able to say -kernel <anything> and it should work. It has worked for me with vmlinux and Image files when using master (not the 4.0 release but master/4.1). Although all of my testing was with the 5.1 kernel, so maybe there is a difference there?
Quoted 4 lines
What isn't working for you? Can you include the errors and output of -d
in_asm?Alistair
Quoted 6 lines
Hi Alistair,
I have come across error before starting target simulation. What I means is to execute
qemu-system-riscv64 -M virt -m 256M -nographic -bios ./opensbi/build/platform/qemu/virt/firmware/fw_jump.elf -kernel vmlinux
then get the error message
rom: requested regions overlap (rom mrom.reset. free=0x000000000001eb7c, addr=0x0000000000001000)
qemu-system-riscv64: rom check and register reset failedQuoted 8 lines
Hmmm.... I don't remember seeing this problem in my testing, but it does seem to make sense.
We have two options here:
1. Use the Image file from Linux 5.0+ (my preferred option as 4.19 is getting old)
2. Use the device loader (documented here:
https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md)Nice doc, this example is exactly what I had in mind:
qemu-system-riscv64 -M virt -m 256M -nographic \ -kernel build/platform/qemu/virt/firmware/fw_jump.elf \ -device loader,file=<linux_build_directory>/arch/riscv/boot/Image,addr=0x80200000 \ -drive file=<path_to_linux_rootfs>,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -append "root=/dev/vda rw console=ttyS0"
Quoted 3 lines
If the Image is an ELF, I assume we don't need to specify the address, because the device loader knows how to parse this format. Again, Alistair is the expert ;)
Yep, an elf should just work.
Quoted 2 lines
If for some reason it only works with Linux 5.0+, let's use these!
Only 5.0+ builds an elf.
Alistair
Quoted 4 lines
Regards,
Phil.
Quoted 188 lines · Alistair Francis
Quoted 3 lines · Philippe Mathieu-Daudé
Quoted 1 line · Alistair Francis
On Tue, Jul 16, 2019 at 6:56 AM Chih-Min Chao <[email protected]>
Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
On Tue, Jul 16, 2019 at 12:34 AM Alistair Francis <
Quoted 10 lines · [email protected]> wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Chih-Min Chao
On Mon, Jul 15, 2019 at 5:15 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 7/15/19 11:08 AM, Chih-Min Chao wrote:
> Similar to the mips + malta test, it boots a Linux kernel ona virt
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
board and verify the serial is working. Also, it relies on
the serial
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
device set by the machine itself.
If riscv64 is a target being built, "make check-acceptance"
will
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
automatically include this test by the use of the
"arch:riscv64" tags.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Alternatively, this test can be run using:
$ avocado run -t arch:riscv64 tests/acceptanceQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
packages
debian officialbinutils-riscv64-linux-gnu_2.32-8 opensbi_0.4-1_all linux-image-4.19.0-5-riscv64 4.19.37-4third-party
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 3 lines
(the repo is also used in mips target acceptance)
Signed-off-by Chih-Min Chao <[email protected]<mailto:[email protected]>> > --- > .travis.yml | 2 +- > tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ > 2 files changed, 67 insertions(+), 1 deletion(-) > > diff --git a/.travis.yml b/.travis.yml > index 5d3d6ee..21fcead 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -232,7 +232,7 @@ matrix: >Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
# Acceptance (Functional) tests
- env:
- - CONFIG="--python=/usr/bin/python3--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu"
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
+ - CONFIG="--python=/usr/bin/python3
--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu"
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Review
Quoted 4 lines
- TEST_CMD="make check-acceptance"
after_failure:
- cat tests/results/latest/job.log(quoted diff) +0
-0
b/tests/acceptance/boot_linux_console.py
> index 3215950..0f638bc 100644
> ---a/tests/acceptance/boot_linux_console.py> +++b/tests/acceptance/boot_linux_console.py> @@ -354,3 +354,69 @@ class BootLinuxConsole(Test):
>self.vm.launch()
>console_pattern= 'Kernel command line: %s' %
kernel_command_lineQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
self.wait_for_console_pattern(console_pattern)(quoted diff) +7
-0+ + def test_riscv64_virt(self): + """ + :avocado: tags=arch:riscv64 + :avocado: tags=machine:virt + """ + deb_url = ('https://snapshot.debian.org/archive/debian/'
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
'20190424T171759Z/pool/main/b/binutils/'
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
+
'binutils-riscv64-linux-gnu_2.32-8_amd64.deb')
> +deb_hash=('
7fe376fd4452696c03acd508d6d613ca553ea15e')Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
deb_path= self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' + objcopy_path = self.extract_from_deb(deb_path,
objcopy_path)Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+
libbfd_path='/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so <http://libbfd-2.32-riscv64.so>' > + libbfd_path = self.extract_from_deb(deb_path,
libbfd_path)Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ process.run('ls -al %s' % (objcopy_path)) + + deb_url = ('https://snapshot.debian.org/archive/debian/'
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ '20190708T032337Z/pool/main/o/opensbi/' + 'opensbi_0.4-1_all.deb') + deb_hash =('
2319dcd702958291d323acf5649fd98a11d90112')Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
deb_path= self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
opensbi_path=('
/usr/lib/riscv64-linux-gnu/opensbi/'Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 'qemu/virt/fw_jump.elf') + opensbi_path = self.extract_from_deb(deb_path,
opensbi_path)Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + deb_url =('https://snapshot.debian.org/archive/debian-ports/' > +'20190620T095935Z/pool-riscv64/main/l/linux/'
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
+
'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb')
> +deb_hash=('
bf5b5680c41d92134d22caef4fbd277c5217e1f0')Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
deb_path= self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' + kernel_path = self.extract_from_deb(deb_path,
kernel_path)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ kimage_path = self.workdir + "/Image" + env = os.environ + env['LD_LIBRARY_PATH'] = ('%s:' %(
os.path.dirname(libbfd_path)) +
> + env.get('LD_LIBRARY_PATH',''))
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ process.run(('%s -O binary -O binary -R' + '.note -R .note.gnu.build-id -R.comment -S
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
%s %s') %
> + (objcopy_path,kernel_path,
kimage_path))Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Please explain why you need to do that...
Also note these tests are run on other host architecture than
x86, at
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
least ppc64/s390x (so this won't work there).it is because riscv64 vmlinux doesn't have physical loading address information and
depends on certain stage bootloader to move kernel raw data tospecific
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
physical address (0x8020_0000)
The vmlinux program headers are
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD0x0010000xffffffe0000000000x0000000000000000
0x0303a6Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
0x0303a6R E0x1000
LOAD0x0320000xffffffe0000310000x0000000000031000
0x828f0cQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
0x828f0cRWE0x1000
NOTE0x85aec00xffffffe000859ec00x0000000000859ec0
0x00004cQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
0x00004cR0x4For legacy bootloader, bbl, It can handle payload in ELF format. However, for the newer OpenSBI, it can only handle raw data and debian doesn't provide linux image in raw data format.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
This doesn't sound right. You should just be able to say -kernel <anything> and it should work. It has worked for me with vmlinux and Image files when using master (not the 4.0 release but master/4.1). Although all of my testing was with the 5.1 kernel, so maybe there is a difference there?
What isn't working for you? Can you include the errors and output of
-d
in_asm?Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Alistair
Quoted 17 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Hi Alistair,
I have come across error before starting target simulation. WhatI means is to execute
Quoted 1 line
Quoted 1 line
Quoted 1 line
qemu-system-riscv64 -M virt -m 256M -nographic -bios
./opensbi/build/platform/qemu/virt/firmware/fw_jump.elf -kernel vmlinux
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
then get the error message
rom: requested regions overlap (rom mrom.reset.free=0x000000000001eb7c, addr=0x0000000000001000)
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
qemu-system-riscv64: rom check and register reset failed
Hmmm.... I don't remember seeing this problem in my testing, but it does seem to make sense.
We have two options here:
1. Use the Image file from Linux 5.0+ (my preferred option as 4.19 is getting old)
I choose 4.19 version rather than 5.0+ because 4.19 is stable branch
maintained by Greg.
But it is ok to use 5.0 trunk, the latest version provided by debian.
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
2. Use the device loader (documented here:
https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md)
The document describes two user cases
1. fw_payload.elf
a. include the Image (raw data file, not elf) into data section b. -kernel load the each part to the correct address
the program header of fw_payload.elf are
Type Offset VirtAddr PhysAddr FileSiz
MemSiz Flg Align
LOAD 0x0000b0 0x0000000080000000 0x0000000080000000 0x00a008
0x00b0b8 RWE 0x10 <- fw_payload main program
LOAD 0x00a0b8 0x0000000080200000 0x0000000080200000 0x8dbe200x8dbe20 R E 0x1 <- arch/riscv/boot/Image or
u-boot.bin
2. fw_jump.elf
a. use "-kernel <raw image> or -device loader,file=<raw
Image>,addr=0x80200000" to load correct address
b. fw_jump.elf just jump to the entry address 0x80200000
The issues are
a. debian linux-image package only provides vmlinux.
so I use objcopy in acceptance test
b. riscv64 vmlinux doesn't have correct PhysAddr and -kernel can't move
data to expected address
explicit load the Image to specific
-kernel raw_image (if file is not elf or uImage,riscv_kerner_loader treat it is as raw image and place it at 0x8020_0000)
-device loader,file=<raw_image>,0x80200000 (do the same thing)
ELF should work only if it has correct loading information.
chihmin.chao
Quoted 33 lines
Quoted 7 lines
Nice doc, this example is exactly what I had in mind:
qemu-system-riscv64 -M virt -m 256M -nographic \ -kernel build/platform/qemu/virt/firmware/fw_jump.elf \ -deviceloader,file=<linux_build_directory>/arch/riscv/boot/Image,addr=0x80200000 \
Quoted 7 lines
-drive file=<path_to_linux_rootfs>,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -append "root=/dev/vda rw console=ttyS0"If the Image is an ELF, I assume we don't need to specify the address, because the device loader knows how to parse this format. Again, Alistair is the expert ;)
Yep, an elf should just work.
describe the issue above
Quoted 2 lines
If for some reason it only works with Linux 5.0+, let's use these!
Only 5.0+ builds an elf.
Alistair
Quoted 4 lines
Regards,
Phil.
Quoted 192 lines · Chih-Min Chao
Quoted 163 lines · Alistair Francis
Quoted 160 lines · Philippe Mathieu-Daudé
Quoted 158 lines · Alistair Francis
Quoted 156 lines · Chih-Min Chao
Quoted 141 lines · Alistair Francis
Quoted 128 lines · Philippe Mathieu-Daudé
Quoted 126 lines · Chih-Min Chao
On Mon, Jul 15, 2019 at 5:15 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 7/15/19 11:08 AM, Chih-Min Chao wrote: > Similar to the mips + malta test, it boots a Linux kernel on a virt > board and verify the serial is working. Also, it relies on the serial > device set by the machine itself. > > If riscv64 is a target being built, "make check-acceptance" will > automatically include this test by the use of the "arch:riscv64" tags. > > Alternatively, this test can be run using: > > $ avocado run -t arch:riscv64 tests/acceptance > > packages > debian official > binutils-riscv64-linux-gnu_2.32-8 > opensbi_0.4-1_all > linux-image-4.19.0-5-riscv64 4.19.37-4 > third-party > https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz > (the repo is also used in mips target acceptance) > > Signed-off-by: Chih-Min Chao <[email protected] <mailto:[email protected]>> > --- > .travis.yml | 2 +- > tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ > 2 files changed, 67 insertions(+), 1 deletion(-) > > diff --git a/.travis.yml b/.travis.yml > index 5d3d6ee..21fcead 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -232,7 +232,7 @@ matrix: > > # Acceptance (Functional) tests > - env: > - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" > + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" > - TEST_CMD="make check-acceptance" > after_failure: > - cat tests/results/latest/job.log > diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py > index 3215950..0f638bc 100644 > --- a/tests/acceptance/boot_linux_console.py > +++ b/tests/acceptance/boot_linux_console.py > @@ -354,3 +354,69 @@ class BootLinuxConsole(Test): > self.vm.launch() > console_pattern = 'Kernel command line: %s' % kernel_command_line > self.wait_for_console_pattern(console_pattern) > + > + def test_riscv64_virt(self): > + """ > + :avocado: tags=arch:riscv64 > + :avocado: tags=machine:virt > + """ > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190424T171759Z/pool/main/b/binutils/' > + 'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') > + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' > + objcopy_path = self.extract_from_deb(deb_path, objcopy_path) > + libbfd_path = '/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so <http://libbfd-2.32-riscv64.so>' > + libbfd_path = self.extract_from_deb(deb_path, libbfd_path) > + process.run('ls -al %s' % (objcopy_path)) > + > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190708T032337Z/pool/main/o/opensbi/' > + 'opensbi_0.4-1_all.deb') > + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' > + 'qemu/virt/fw_jump.elf') > + opensbi_path = self.extract_from_deb(deb_path, opensbi_path) > + > + deb_url = ('https://snapshot.debian.org/archive/debian-ports/' > + '20190620T095935Z/pool-riscv64/main/l/linux/' > + 'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb') > + deb_hash = ('bf5b5680c41d92134d22caef4fbd277c5217e1f0') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' > + kernel_path = self.extract_from_deb(deb_path, kernel_path) > + kimage_path = self.workdir + "/Image" > + env = os.environ > + env['LD_LIBRARY_PATH'] = ('%s:' % (os.path.dirname(libbfd_path)) + > + env.get('LD_LIBRARY_PATH', '')) > + process.run(('%s -O binary -O binary -R' > + '.note -R .note.gnu.build-id -R .comment -S %s %s') % > + (objcopy_path, kernel_path, kimage_path)) Please explain why you need to do that... Also note these tests are run on other host architecture than x86, at least ppc64/s390x (so this won't work there).it is because riscv64 vmlinux doesn't have physical loading address information and
depends on certain stage bootloader to move kernel raw data to specific physical address (0x8020_0000)The vmlinux program headers are
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD0x0010000xffffffe0000000000x00000000000000000x0303a60x0303a6R E0x1000
LOAD0x0320000xffffffe0000310000x00000000000310000x828f0c0x828f0cRWE0x1000
NOTE0x85aec00xffffffe000859ec00x0000000000859ec00x00004c0x00004cR0x4Quoted 3 lines
Quoted 3 lines
For legacy bootloader, bbl, It can handle payload in ELF format. However, for the newer OpenSBI, it can only handle raw data and debian doesn't provide linux image in raw data format.
This doesn't sound right. You should just be able to say -kernel <anything> and it should work. It has worked for me with vmlinux and Image files when using master (not the 4.0 release but master/4.1). Although all of my testing was with the 5.1 kernel, so maybe there is a difference there?
Quoted 4 lines
What isn't working for you? Can you include the errors and output of -d
in_asm?Alistair
Hi Alistair,
I have come across error before starting target simulation. What I means is to execute
qemu-system-riscv64 -M virt -m 256M -nographic -bios ./opensbi/build/platform/qemu/virt/firmware/fw_jump.elf -kernel vmlinux
then get the error message
rom: requested regions overlap (rom mrom.reset. free=0x000000000001eb7c, addr=0x0000000000001000)
qemu-system-riscv64: rom check and register reset failedQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Hmmm.... I don't remember seeing this problem in my testing, but it does seem to make sense.
We have two options here:
1. Use the Image file from Linux 5.0+ (my preferred option as 4.19 is getting old)I choose 4.19 version rather than 5.0+ because 4.19 is stable branch maintained by Greg. But it is ok to use 5.0 trunk, the latest version provided by debian.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
2. Use the device loader (documented here:
https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md)The document describes two user cases
1. fw_payload.elf
a. include the Image (raw data file, not elf) into data section b. -kernel load the each part to the correct addressthe program header of fw_payload.elf are
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD0x0000b00x00000000800000000x00000000800000000x00a0080x00b0b8RWE0x10<-fw_payloadmain program
LOAD0x00a0b80x00000000802000000x00000000802000000x8dbe200x8dbe20R E0x1<-arch/riscv/boot/Imageor u-boot.bin
Quoted 7 lines
2. fw_jump.elf
a. use "-kernel <raw image> or -device loader,file=<raw Image>,addr=0x80200000" to load correct address b. fw_jump.elf just jump to the entry address 0x80200000The issues are
a. debian linux-image package only provides vmlinux.
This can be fixed by upgrading the kernel version. Fedora should have a 5.2 kernel that you can use instead of Debian.
Quoted 5 lines
so I use objcopy in acceptance test
b. riscv64 vmlinux doesn't have correct PhysAddr and -kernel can't move data to expected addressexplicit load the Image to specific -kernel raw_image (if file is not elf or uImage, riscv_kerner_loader treat it is as raw image and place it at 0x8020_0000) -device loader,file=<raw_image>,0x80200000 (do the same thing)
Does the device loader not work?
Alistair
Quoted 36 lines
ELF should work only if it has correct loading information.
chihmin.chao
Quoted 12 lines
Quoted 12 lines
Nice doc, this example is exactly what I had in mind:
qemu-system-riscv64 -M virt -m 256M -nographic \ -kernel build/platform/qemu/virt/firmware/fw_jump.elf \ -device loader,file=<linux_build_directory>/arch/riscv/boot/Image,addr=0x80200000 \ -drive file=<path_to_linux_rootfs>,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -append "root=/dev/vda rw console=ttyS0"Quoted 6 lines
Quoted 3 lines
If the Image is an ELF, I assume we don't need to specify the address, because the device loader knows how to parse this format. Again, Alistair is the expert ;)
Yep, an elf should just work.
describe the issue above
Quoted 12 lines
Quoted 3 lines
If for some reason it only works with Linux 5.0+, let's use these!
Only 5.0+ builds an elf.
Alistair
Quoted 4 lines
Regards,
Phil.
Quoted 263 lines · Alistair Francis
Quoted 4 lines · Chih-Min Chao
On Wed, Jul 17, 2019 at 6:59 AM Alistair Francis <[email protected]>
Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 3 lines · Philippe Mathieu-Daudé
Quoted 1 line · Alistair Francis
On Tue, Jul 16, 2019 at 6:56 AM Chih-Min Chao <
Quoted 3 lines · [email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
On Tue, Jul 16, 2019 at 12:34 AM Alistair Francis <
Quoted 10 lines · [email protected]> wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Chih-Min Chao
On Mon, Jul 15, 2019 at 5:15 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 7/15/19 11:08 AM, Chih-Min Chao wrote:
> Similar to the mips + malta test, it boots a Linux kernelon a virt
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
board and verify the serial is working. Also, it relies
on the serial
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
device set by the machine itself.
If riscv64 is a target being built, "make
check-acceptance" will
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
automatically include this test by the use of the
"arch:riscv64" tags.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Alternatively, this test can be run using:
$ avocado run -t arch:riscv64 tests/acceptanceQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
packages
debian officialbinutils-riscv64-linux-gnu_2.32-8 opensbi_0.4-1_all linux-image-4.19.0-5-riscv64 4.19.37-4third-party
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 3 lines
(the repo is also used in mips target acceptance)
Signed-off-by Chih-Min Chao <[email protected]<mailto:[email protected]>> > --- > .travis.yml | 2 +- > tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ > 2 files changed, 67 insertions(+), 1 deletion(-) > > diff --git a/.travis.yml b/.travis.yml > index 5d3d6ee..21fcead 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -232,7 +232,7 @@ matrix: >Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
# Acceptance (Functional) tests
- env:
- - CONFIG="--python=/usr/bin/python3--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu"
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
+ - CONFIG="--python=/usr/bin/python3
--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu"
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Review
Quoted 4 lines
- TEST_CMD="make check-acceptance"
after_failure:
- cat tests/results/latest/job.log(quoted diff) +0
-0
b/tests/acceptance/boot_linux_console.py
> index 3215950..0f638bc 100644
> ---a/tests/acceptance/boot_linux_console.py> +++b/tests/acceptance/boot_linux_console.py> @@ -354,3 +354,69 @@ class BootLinuxConsole(Test):
>self.vm.launch()
>console_pattern= 'Kernel command line: %s' %
kernel_command_lineQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
self.wait_for_console_pattern(console_pattern)(quoted diff) +7
-0+ + def test_riscv64_virt(self): + """ + :avocado: tags=arch:riscv64 + :avocado: tags=machine:virt + """ + deb_url = ('https://snapshot.debian.org/archive/debian/'
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
'20190424T171759Z/pool/main/b/binutils/'
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
+
'binutils-riscv64-linux-gnu_2.32-8_amd64.deb')
> +deb_hash=('
7fe376fd4452696c03acd508d6d613ca553ea15e')Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
deb_path= self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
objcopy_path='
/usr/bin/riscv64-linux-gnu-objcopy'Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
objcopy_path= self.extract_from_deb(deb_path,
objcopy_path)Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+
libbfd_path='/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so <http://libbfd-2.32-riscv64.so>' > + libbfd_path = self.extract_from_deb(deb_path,
libbfd_path)Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ process.run('ls -al %s' % (objcopy_path)) + + deb_url = ('https://snapshot.debian.org/archive/debian/'
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
'20190708T032337Z/pool/main/o/opensbi/'
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 'opensbi_0.4-1_all.deb') + deb_hash =('
2319dcd702958291d323acf5649fd98a11d90112')Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
deb_path= self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
opensbi_path=('
/usr/lib/riscv64-linux-gnu/opensbi/'Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 'qemu/virt/fw_jump.elf') + opensbi_path = self.extract_from_deb(deb_path,
opensbi_path)Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + deb_url =('https://snapshot.debian.org/archive/debian-ports/' > +'20190620T095935Z/pool-riscv64/main/l/linux/'
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
+
'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb')
> +deb_hash=('
bf5b5680c41d92134d22caef4fbd277c5217e1f0')Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
deb_path= self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' + kernel_path = self.extract_from_deb(deb_path,
kernel_path)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ kimage_path = self.workdir + "/Image" + env = os.environ + env['LD_LIBRARY_PATH'] = ('%s:' %(os.path.dirname(libbfd_path)) + > +
env.get('LD_LIBRARY_PATH', ''))Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ process.run(('%s -O binary -O binary -R' + '.note -R .note.gnu.build-id -R.comment -S
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
%s %s') %
> + (objcopy_path,kernel_path,
kimage_path))Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Please explain why you need to do that...
Also note these tests are run on other host architecture
than x86, at
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
least ppc64/s390x (so this won't work there).it is because riscv64 vmlinux doesn't have physical loading
address
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
information and
depends on certain stage bootloader to move kernel raw data tospecific
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
physical address (0x8020_0000)
The vmlinux program headers are
Type Offset VirtAddrPhysAddr
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
FileSiz MemSiz Flg Align
LOAD0x0010000xffffffe0000000000x0000000000000000
0x0303a6Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
0x0303a6R E0x1000
LOAD0x0320000xffffffe0000310000x0000000000031000
0x828f0cQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
0x828f0cRWE0x1000
NOTE0x85aec00xffffffe000859ec00x0000000000859ec0
0x00004cQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
0x00004cR0x4For legacy bootloader, bbl, It can handle payload in ELF format. However, for the newer OpenSBI, it can only handle raw data and debian doesn't provide linux image in raw data format.
This doesn't sound right. You should just be able to say -kernel <anything> and it should work. It has worked for me with vmlinux
and
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Image files when using master (not the 4.0 release but
master/4.1).
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Although all of my testing was with the 5.1 kernel, so maybe
there is
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
a difference there?
What isn't working for you? Can you include the errors and output
of -d
in_asm?Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Alistair
Hi Alistair,
I have come across error before starting target simulation.What I means is to execute
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
qemu-system-riscv64 -M virt -m 256M -nographic -bios
./opensbi/build/platform/qemu/virt/firmware/fw_jump.elf -kernel vmlinux
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
then get the error message
rom: requested regions overlap (rom mrom.reset.free=0x000000000001eb7c, addr=0x0000000000001000)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
qemu-system-riscv64: rom check and register reset
failed
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Hmmm.... I don't remember seeing this problem in my testing, but it does seem to make sense.
We have two options here:
1. Use the Image file from Linux 5.0+ (my preferred option as 4.19is
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
getting old)
I choose 4.19 version rather than 5.0+ because 4.19 is stable branch
maintained by Greg.
Quoted 5 lines
But it is ok to use 5.0 trunk, the latest version provided by debian.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
2. Use the device loader (documented here:
https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md)
Quoted 9 lines
The document describes two user cases
1. fw_payload.elf
a. include the Image (raw data file, not elf) into data section b. -kernel load the each part to the correct addressthe program header of fw_payload.elf are
Type Offset VirtAddr PhysAddrFileSiz MemSiz Flg Align
Quoted 1 line
LOAD 0x0000b0 0x0000000080000000 0x0000000080000000
0x00a0080x00b0b8RWE0x10<-fw_payloadmain programQuoted 1 line
LOAD 0x00a0b8 0x0000000080200000 0x0000000080200000
0x8dbe200x8dbe20R E0x1<-arch/riscv/boot/Imageor
u-boot.binQuoted 3 lines
2. fw_jump.elf
a. use "-kernel <raw image> or -device loader,file=<rawImage>,addr=0x80200000" to load correct address
Quoted 5 lines
b. fw_jump.elf just jump to the entry address 0x80200000The issues are
a. debian linux-image package only provides vmlinux.This can be fixed by upgrading the kernel version. Fedora should have a 5.2 kernel that you can use instead of Debian.
Quoted 2 lines
so I use objcopy in acceptance test
b. riscv64 vmlinux doesn't have correct PhysAddr and -kernel can'tmove data to expected address
Quoted 2 lines
explicit load the Image to specific
-kernelraw_image(if file is not elf or uImage,
Quoted 8 lines
riscv_kerner_loadertreat it is as raw image and place it at 0x8020_0000)Quoted 1 line
-device loader,file=<raw_image>,0x80200000 (do the samething)
Does the device loader not work?
Alistair
The device loader works for "Image" case (raw data)
If the data is raw image, for riscv_load_kernel implementation,
"-kernel <raw_image>" and -device loader,file=<raw_image>,0x80200000 are
the same.
They finally call "load_image_targphys_as"
The only difference is that target address is hardcoded or feed from
command line option.
I don't prefe one than the other. Both of them are Ok to me. I could
refine that if one of them is more preferable.
chihmin.chao
Quoted 39 lines
Quoted 13 lines
ELF should work only if it has correct loading information.
chihmin.chao
Quoted 8 lines
Quoted 8 lines
Nice doc, this example is exactly what I had in mind:
qemu-system-riscv64 -M virt -m 256M -nographic \ -kernel build/platform/qemu/virt/firmware/fw_jump.elf \ -deviceloader,file=<linux_build_directory>/arch/riscv/boot/Image,addr=0x80200000 \
Quoted 24 lines
Quoted 10 lines
Quoted 7 lines
-drive file=<path_to_linux_rootfs>,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -append "root=/dev/vda rw console=ttyS0"If the Image is an ELF, I assume we don't need to specify the address, because the device loader knows how to parse this format. Again, Alistair is the expert ;)
Yep, an elf should just work.
describe the issue above
Quoted 12 lines
Quoted 3 lines
If for some reason it only works with Linux 5.0+, let's use these!
Only 5.0+ builds an elf.
Alistair
Quoted 4 lines
Regards,
Phil.
Quoted 220 lines · Chih-Min Chao
Quoted 211 lines · Alistair Francis
Quoted 192 lines · Chih-Min Chao
Quoted 163 lines · Alistair Francis
Quoted 160 lines · Philippe Mathieu-Daudé
Quoted 158 lines · Alistair Francis
Quoted 156 lines · Chih-Min Chao
Quoted 141 lines · Alistair Francis
Quoted 128 lines · Philippe Mathieu-Daudé
Quoted 126 lines · Chih-Min Chao
On Mon, Jul 15, 2019 at 5:15 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 7/15/19 11:08 AM, Chih-Min Chao wrote: > Similar to the mips + malta test, it boots a Linux kernel on a virt > board and verify the serial is working. Also, it relies on the serial > device set by the machine itself. > > If riscv64 is a target being built, "make check-acceptance" will > automatically include this test by the use of the "arch:riscv64" tags. > > Alternatively, this test can be run using: > > $ avocado run -t arch:riscv64 tests/acceptance > > packages > debian official > binutils-riscv64-linux-gnu_2.32-8 > opensbi_0.4-1_all > linux-image-4.19.0-5-riscv64 4.19.37-4 > third-party > https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz > (the repo is also used in mips target acceptance) > > Signed-off-by: Chih-Min Chao <[email protected] <mailto:[email protected]>> > --- > .travis.yml | 2 +- > tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ > 2 files changed, 67 insertions(+), 1 deletion(-) > > diff --git a/.travis.yml b/.travis.yml > index 5d3d6ee..21fcead 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -232,7 +232,7 @@ matrix: > > # Acceptance (Functional) tests > - env: > - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" > + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" > - TEST_CMD="make check-acceptance" > after_failure: > - cat tests/results/latest/job.log > diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py > index 3215950..0f638bc 100644 > --- a/tests/acceptance/boot_linux_console.py > +++ b/tests/acceptance/boot_linux_console.py > @@ -354,3 +354,69 @@ class BootLinuxConsole(Test): > self.vm.launch() > console_pattern = 'Kernel command line: %s' % kernel_command_line > self.wait_for_console_pattern(console_pattern) > + > + def test_riscv64_virt(self): > + """ > + :avocado: tags=arch:riscv64 > + :avocado: tags=machine:virt > + """ > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190424T171759Z/pool/main/b/binutils/' > + 'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') > + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' > + objcopy_path = self.extract_from_deb(deb_path, objcopy_path) > + libbfd_path = '/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so <http://libbfd-2.32-riscv64.so>' > + libbfd_path = self.extract_from_deb(deb_path, libbfd_path) > + process.run('ls -al %s' % (objcopy_path)) > + > + deb_url = ('https://snapshot.debian.org/archive/debian/' > + '20190708T032337Z/pool/main/o/opensbi/' > + 'opensbi_0.4-1_all.deb') > + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' > + 'qemu/virt/fw_jump.elf') > + opensbi_path = self.extract_from_deb(deb_path, opensbi_path) > + > + deb_url = ('https://snapshot.debian.org/archive/debian-ports/' > + '20190620T095935Z/pool-riscv64/main/l/linux/' > + 'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb') > + deb_hash = ('bf5b5680c41d92134d22caef4fbd277c5217e1f0') > + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) > + kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' > + kernel_path = self.extract_from_deb(deb_path, kernel_path) > + kimage_path = self.workdir + "/Image" > + env = os.environ > + env['LD_LIBRARY_PATH'] = ('%s:' % (os.path.dirname(libbfd_path)) + > + env.get('LD_LIBRARY_PATH', '')) > + process.run(('%s -O binary -O binary -R' > + '.note -R .note.gnu.build-id -R .comment -S %s %s') % > + (objcopy_path, kernel_path, kimage_path)) Please explain why you need to do that... Also note these tests are run on other host architecture than x86, at least ppc64/s390x (so this won't work there).it is because riscv64 vmlinux doesn't have physical loading address information and
depends on certain stage bootloader to move kernel raw data to specific physical address (0x8020_0000)The vmlinux program headers are
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD0x0010000xffffffe0000000000x00000000000000000x0303a60x0303a6R E0x1000
LOAD0x0320000xffffffe0000310000x00000000000310000x828f0c0x828f0cRWE0x1000
NOTE0x85aec00xffffffe000859ec00x0000000000859ec00x00004c0x00004cR0x4Quoted 3 lines
Quoted 3 lines
For legacy bootloader, bbl, It can handle payload in ELF format. However, for the newer OpenSBI, it can only handle raw data and debian doesn't provide linux image in raw data format.
This doesn't sound right. You should just be able to say -kernel <anything> and it should work. It has worked for me with vmlinux and Image files when using master (not the 4.0 release but master/4.1). Although all of my testing was with the 5.1 kernel, so maybe there is a difference there?
Quoted 4 lines
What isn't working for you? Can you include the errors and output of -d
in_asm?Alistair
Hi Alistair,
I have come across error before starting target simulation. What I means is to execute
qemu-system-riscv64 -M virt -m 256M -nographic -bios ./opensbi/build/platform/qemu/virt/firmware/fw_jump.elf -kernel vmlinux
then get the error message
rom: requested regions overlap (rom mrom.reset. free=0x000000000001eb7c, addr=0x0000000000001000)
qemu-system-riscv64: rom check and register reset failedQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Hmmm.... I don't remember seeing this problem in my testing, but it does seem to make sense.
We have two options here:
1. Use the Image file from Linux 5.0+ (my preferred option as 4.19 is getting old)I choose 4.19 version rather than 5.0+ because 4.19 is stable branch maintained by Greg. But it is ok to use 5.0 trunk, the latest version provided by debian.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
2. Use the device loader (documented here:
https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md)The document describes two user cases
1. fw_payload.elf
a. include the Image (raw data file, not elf) into data section b. -kernel load the each part to the correct addressthe program header of fw_payload.elf are
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD0x0000b00x00000000800000000x00000000800000000x00a0080x00b0b8RWE0x10<-fw_payloadmain program
LOAD0x00a0b80x00000000802000000x00000000802000000x8dbe200x8dbe20R E0x1<-arch/riscv/boot/Imageor u-boot.binQuoted 7 lines
2. fw_jump.elf
a. use "-kernel <raw image> or -device loader,file=<raw Image>,addr=0x80200000" to load correct address b. fw_jump.elf just jump to the entry address 0x80200000The issues are
a. debian linux-image package only provides vmlinux.This can be fixed by upgrading the kernel version. Fedora should have a 5.2 kernel that you can use instead of Debian.
Quoted 5 lines
so I use objcopy in acceptance test
b. riscv64 vmlinux doesn't have correct PhysAddr and -kernel can't move data to expected addressexplicit load the Image to specific -kernel raw_image (if file is not elf or uImage, riscv_kerner_loader treat it is as raw image and place it at 0x8020_0000) -device loader,file=<raw_image>,0x80200000 (do the same thing)Quoted 3 lines
Does the device loader not work?
Alistair
Quoted 6 lines
The device loader works for "Image" case (raw data)
If the data is raw image, forriscv_load_kernelimplementation, "-kernel <raw_image>" and -device loader,file=<raw_image>,0x80200000 are the same.
They finally call "load_image_targphys_as"
The only difference is that target address is hardcoded or feed from command line option.I don't prefe one than the other. Both of them are Ok to me. I could refine that if one of them is more preferable.
I'm a little confused with what you mean, so if you have something that will work just send a new version and we can discuss it there.
PS: I'm still in favour of just using a newer kernel and a Image file.
Alistair
Quoted 41 lines
chihmin.chao
Quoted 38 lines
Quoted 38 lines
ELF should work only if it has correct loading information.
chihmin.chao
Quoted 12 lines
Quoted 12 lines
Nice doc, this example is exactly what I had in mind:
qemu-system-riscv64 -M virt -m 256M -nographic \ -kernel build/platform/qemu/virt/firmware/fw_jump.elf \ -device loader,file=<linux_build_directory>/arch/riscv/boot/Image,addr=0x80200000 \ -drive file=<path_to_linux_rootfs>,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -append "root=/dev/vda rw console=ttyS0"Quoted 6 lines
Quoted 3 lines
If the Image is an ELF, I assume we don't need to specify the address, because the device loader knows how to parse this format. Again, Alistair is the expert ;)
Yep, an elf should just work.
describe the issue above
Quoted 12 lines
Quoted 3 lines
If for some reason it only works with Linux 5.0+, let's use these!
Only 5.0+ builds an elf.
Alistair
Quoted 4 lines
Regards,
Phil.
Quoted 296 lines · Alistair Francis
Quoted 4 lines · Chih-Min Chao
On Thu, Jul 18, 2019 at 6:47 AM Alistair Francis <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
On Tue, Jul 16, 2019 at 10:21 PM Chih-Min Chao <[email protected]>
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
On Wed, Jul 17, 2019 at 6:59 AM Alistair Francis <
Quoted 6 lines · [email protected]> wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines · Philippe Mathieu-Daudé
Quoted 1 line · Alistair Francis
On Tue, Jul 16, 2019 at 6:56 AM Chih-Min Chao <
Quoted 3 lines · [email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
On Tue, Jul 16, 2019 at 12:34 AM Alistair Francis <
Quoted 10 lines · [email protected]> wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Chih-Min Chao
On Mon, Jul 15, 2019 at 5:15 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 7/15/19 11:08 AM, Chih-Min Chao wrote:
> Similar to the mips + malta test, it boots a Linuxkernel on a virt
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
board and verify the serial is working. Also, it
relies on the serial
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
device set by the machine itself.
If riscv64 is a target being built, "make
check-acceptance" will
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
automatically include this test by the use of the
"arch:riscv64" tags.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Alternatively, this test can be run using:
$ avocado run -t arch:riscv64 tests/acceptanceQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
packages
debian officialbinutils-riscv64-linux-gnu_2.32-8 opensbi_0.4-1_all linux-image-4.19.0-5-riscv64 4.19.37-4third-party
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 3 lines
(the repo is also used in mips target acceptance)
Signed-off-by Chih-Min Chao <[email protected]<mailto:[email protected]>> > --- > .travis.yml | 2 +- > tests/acceptance/boot_linux_console.py | 66 ++++++++++++++++++++++++++++++++++ > 2 files changed, 67 insertions(+), 1 deletion(-) > > diff --git a/.travis.yml b/.travis.yml > index 5d3d6ee..21fcead 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -232,7 +232,7 @@ matrix: >Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
# Acceptance (Functional) tests
- env:
- - CONFIG="--python=/usr/bin/python3--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu"
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
+ - CONFIG="--python=/usr/bin/python3
--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu"
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Review
Quoted 4 lines
- TEST_CMD="make check-acceptance"
after_failure:
- cat tests/results/latest/job.log(quoted diff) +0
-0
b/tests/acceptance/boot_linux_console.py
> index 3215950..0f638bc 100644
> ---a/tests/acceptance/boot_linux_console.py> +++b/tests/acceptance/boot_linux_console.py> @@ -354,3 +354,69 @@ class BootLinuxConsole(Test):
>self.vm.launch()
>console_pattern= 'Kernel command line: %s' %
kernel_command_lineQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
self.wait_for_console_pattern(console_pattern)(quoted diff) +7
-0+ + def test_riscv64_virt(self): + """ + :avocado: tags=arch:riscv64 + :avocado: tags=machine:virt + """ + deb_url = ('https://snapshot.debian.org/archive/debian/'
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
'20190424T171759Z/pool/main/b/binutils/'
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
+
'binutils-riscv64-linux-gnu_2.32-8_amd64.deb')
> +deb_hash=('
7fe376fd4452696c03acd508d6d613ca553ea15e')Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
deb_path= self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
objcopy_path='
/usr/bin/riscv64-linux-gnu-objcopy'Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
objcopy_path=
self.extract_from_deb(deb_path, objcopy_path)Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+
libbfd_path='/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so <http://libbfd-2.32-riscv64.so>' > + libbfd_path = self.extract_from_deb(deb_path,
libbfd_path)Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ process.run('ls -al %s' % (objcopy_path)) + + deb_url = ('https://snapshot.debian.org/archive/debian/'
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
'20190708T032337Z/pool/main/o/opensbi/'
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 'opensbi_0.4-1_all.deb') + deb_hash =('
2319dcd702958291d323acf5649fd98a11d90112')Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
deb_path= self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
opensbi_path=('
/usr/lib/riscv64-linux-gnu/opensbi/'Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 'qemu/virt/fw_jump.elf') + opensbi_path =
self.extract_from_deb(deb_path, opensbi_path)Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + deb_url =('https://snapshot.debian.org/archive/debian-ports/' > +'20190620T095935Z/pool-riscv64/main/l/linux/'
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
+
'linux-image-4.19.0-5-riscv64_4.19.37-4_riscv64.deb')
> +deb_hash=('
bf5b5680c41d92134d22caef4fbd277c5217e1f0')Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
deb_path= self.fetch_asset(deb_url,asset_hash=deb_hash)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ kernel_path = '/boot/vmlinux-4.19.0-5-riscv64' + kernel_path = self.extract_from_deb(deb_path,
kernel_path)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ kimage_path = self.workdir + "/Image" + env = os.environ + env['LD_LIBRARY_PATH'] = ('%s:' %(os.path.dirname(libbfd_path)) + > +
env.get('LD_LIBRARY_PATH', ''))Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ process.run(('%s -O binary -O binary -R' + '.note -R .note.gnu.build-id -R.comment -S
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
%s %s') %
> + (objcopy_path,kernel_path,
kimage_path))Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Please explain why you need to do that...
Also note these tests are run on other host architecture
than x86, at
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
least ppc64/s390x (so this won't work there).it is because riscv64 vmlinux doesn't have physical loading
address
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
information and
depends on certain stage bootloader to move kernel raw datato specific
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
physical address (0x8020_0000)
The vmlinux program headers are
Type Offset VirtAddrPhysAddr
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
FileSiz MemSiz Flg Align
LOAD0x0010000xffffffe000000000
0x00000000000000000x0303a6Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
0x0303a6R E0x1000
LOAD0x0320000xffffffe000031000
0x00000000000310000x828f0cQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
0x828f0cRWE0x1000
NOTE0x85aec00xffffffe000859ec0
0x0000000000859ec00x00004cQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
0x00004cR0x4For legacy bootloader, bbl, It can handle payload in ELF
format.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
However, for the newer OpenSBI, it can only handle raw data
and
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
debian doesn't provide linux image in raw data format.
This doesn't sound right. You should just be able to say
-kernel
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
<anything> and it should work. It has worked for me with
vmlinux and
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Image files when using master (not the 4.0 release but
master/4.1).
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Although all of my testing was with the 5.1 kernel, so maybe
there is
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
a difference there?
What isn't working for you? Can you include the errors and
output of -d
in_asm?Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Alistair
Hi Alistair,
I have come across error before starting target simulation.What I means is to execute
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
qemu-system-riscv64 -M virt -m 256M -nographic
-bios ./opensbi/build/platform/qemu/virt/firmware/fw_jump.elf -kernel vmlinux
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
then get the error message
rom: requested regions overlap (rom mrom.reset.free=0x000000000001eb7c, addr=0x0000000000001000)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
qemu-system-riscv64: rom check and register reset
failed
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Hmmm.... I don't remember seeing this problem in my testing, but
it
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
does seem to make sense.
We have two options here:
1. Use the Image file from Linux 5.0+ (my preferred option as4.19 is
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
getting old)
I choose 4.19 version rather than 5.0+ because 4.19 is stable
branch maintained by Greg.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
But it is ok to use 5.0 trunk, the latest version provided by debian.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
2. Use the device loader (documented here:
https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md)
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
The document describes two user cases
1. fw_payload.elf
a. include the Image (raw data file, not elf) into data section b. -kernel load the each part to the correct addressthe program header of fw_payload.elf are
Type Offset VirtAddr PhysAddrFileSiz MemSiz Flg Align
Quoted 1 line
Quoted 1 line
Quoted 1 line
LOAD 0x0000b0 0x0000000080000000 0x0000000080000000
0x00a0080x00b0b8RWE0x10<-fw_payloadmain programQuoted 1 line
Quoted 1 line
Quoted 1 line
LOAD 0x00a0b8 0x0000000080200000 0x0000000080200000
0x8dbe200x8dbe20R E0x1<-arch/riscv/boot/Imageor
u-boot.binQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
2. fw_jump.elf
a. use "-kernel <raw image> or -device loader,file=<rawImage>,addr=0x80200000" to load correct address
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
b. fw_jump.elf just jump to the entry address 0x80200000The issues are
a. debian linux-image package only provides vmlinux.This can be fixed by upgrading the kernel version. Fedora should have a 5.2 kernel that you can use instead of Debian.
Quoted 2 lines
so I use objcopy in acceptance test
b. riscv64 vmlinux doesn't have correct PhysAddr and -kernel can'tmove data to expected address
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
explicit load the Image to specific
-kernelraw_image(if file is not elf or uImage,
riscv_kerner_loadertreat it is as raw image and place it at 0x8020_0000)Quoted 1 line
Quoted 1 line
Quoted 1 line
-device loader,file=<raw_image>,0x80200000 (do the samething)
Quoted 8 lines
Quoted 4 lines
Does the device loader not work?
Alistair
The device loader works for "Image" case (raw data) If the data is raw image, for
riscv_load_kernelimplementation,"-kernel <
raw_image>" and -device loader,file=<raw_image>,0x80200000 are
the same.Quoted 2 lines
They finally call "
load_image_targphys_as"
The only difference is that target address is hardcoded or feed fromcommand line option.
Quoted 2 lines
I don't prefe one than the other. Both of them are Ok to me. I could
refine that if one of them is more preferable.
Quoted 8 lines
I'm a little confused with what you mean, so if you have something that will work just send a new version and we can discuss it there.
PS: I'm still in favour of just using a newer kernel and a Image file.
Alistair
ok, I will use the latest kernel available in Debian package and refine
the command in next version.
chihmin.chao
Quoted 44 lines
Quoted 17 lines
chihmin.chao
Quoted 14 lines
Quoted 14 lines
ELF should work only if it has correct loading information.
chihmin.chao
Quoted 8 lines
Quoted 8 lines
Nice doc, this example is exactly what I had in mind:
qemu-system-riscv64 -M virt -m 256M -nographic \ -kernel build/platform/qemu/virt/firmware/fw_jump.elf \ -deviceloader,file=<linux_build_directory>/arch/riscv/boot/Image,addr=0x80200000 \
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
-drive file=<path_to_linux_rootfs>,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -append "root=/dev/vda rw console=ttyS0"If the Image is an ELF, I assume we don't need to specify the
address,
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 5 lines
Quoted 2 lines
because the device loader knows how to parse this format. Again, Alistair is the expert ;)
Yep, an elf should just work.
describe the issue above
Quoted 12 lines
Quoted 3 lines
If for some reason it only works with Linux 5.0+, let's use these!
Only 5.0+ builds an elf.
Alistair
Quoted 4 lines
Regards,
Phil.